d={'hello':10,'world':20,'php':30}
# 访问
print(d['hello'])
print(d.get('world'))
# 两者是有区别的，当key不存在时，d[key]会报错；d.get(key)不会报错，输出为None，而且可以指定默认值
# print(d['java'])报错
print(d.get('java'))#None
print(d.get('python',40))

# 字典的遍历
for item in d.items():
   print(item)

for key,value in d.items():
    print(key,value)